package com.cn.wanxi.servlet;

import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.service.ICompanyService;
import com.cn.wanxi.service.INavService;
import com.cn.wanxi.service.impl.CompanyServiceImpl;
import com.cn.wanxi.service.impl.NavServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/home")
public class HomeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ICompanyService iCompanyService=new CompanyServiceImpl();
//        重定向
        req.setAttribute("companyModel", iCompanyService.getCompanyModel());



        INavService navService = new NavServiceImpl();//调用导航服务逻辑层
        List<NavModel> navList = navService.getNavList();
        req.setAttribute("navList", navList);
////        新闻板块数据
//        NewsService newsService = new NewsService();
//        List<NewsModel> newsModelList = newsService.getNewsListForHome();
//        req.setAttribute("newsModelList", newsModelList);
//
//
////        产品展示数据
//        ProductService productService = new ProductService();
//        List<ProducctModel> producctModelList = productService.getProductListForHome();
//        req.setAttribute("producctModelList", producctModelList);
//        页面转发
        req.getRequestDispatcher("jsp/home.jsp").forward(req, resp);
    }
    /**
     * 1.面向对象分析对象
     * 2.<%%><%=%><%!%>
     *  3.${}
     *  4.对象的创建（属性，方法，构造方法，方法块）
     *  5.基本数据类型 八种   默认值， 取值范围，类型转换 强转  字节
     *  6.页面转发
     *   req.setAttribute("companyModel", companyModel);
     *   req.getRequestDispatcher("jsp/home.jsp").forward(req, resp);
     *   7. model 里面属性全部用私有
     *   8.权限修饰符
     *   9.数组定义 数组赋值
     *   10.类的加载属性
     *   11.dubug
     *   12：list
     *   13.
     */
}

